import request from "@/plugins/request";

var pre = "/inteCater/foodBeverages/dishReserve";

if (process.env.NODE_ENV !== "development") {
  pre = "/api/sa/smar-catering" + pre;
}

// 检查当天是否有秒杀
export function checkIsSeckill(data) {
  return request({
    url: `${pre}/checkIsSeckill`,
    method: "post",
    data,
  });
}

// 获取菜肴信息
export function getCookbookDishInfo(data) {
  return request({
    url: `${pre}/getCookbookDishInfo`,
    method: "post",
    data,
  });
}

// 获取餐次配置信息
export function getMealsTypeConfigInfo(data) {
  return request({
    url: `${pre}/getMealsTypeConfigInfo`,
    method: "post",
    data,
  });
}

// 获取菜品信息和推荐信息
export function getVarietyInfoAndIsRecommend(data) {
  return request({
    url: `${pre}/getVarietyInfoAndIsRecommend`,
    method: "post",
    data,
  });
}

// 加入购物车
export function addToCart(data) {
  return request({
    url: `${pre}/addToCart`,
    method: "post",
    data,
  });
}

// 获取餐次信息
export function getMealsTypeInfo(data) {
  return request({
    url: `${pre}/getMealsTypeInfo`,
    method: "post",
    data,
  });
}

// 获取当前登录用户购物车数量
export function getCarNumByLoginUser() {
  return request({
    url: `${pre}/getCarNumByLoginUser`,
    method: "get",
  });
}

// 获取当前登录用户购物车信息
export function getCartInByLoginUser() {
  return request({
    url: `${pre}/getCartInByLoginUser`,
    method: "get",
  });
}

// 删除购物车
export function delCart(data) {
  return request({
    url: `${pre}/delCart`,
    method: "post",
    data
  });
}

// 结算购物车
export function settlementCart(data) {
  return request({
    url: `${pre}/settlementCart`,
    method: "post",
    data,
  });
}

// 校验数量加减
export function editNumAddAndDel(data) {
  return request({
    url: `${pre}/editNumAddAndDel`,
    method: "post",
    data,
  });
}

// 提交订单
export function addPlaceOrder(data) {
  return request({
    url: `${pre}/addPlaceOrder`,
    method: "post",
    data,
  });
}

// 支付
export function payment(data) {
  return request({
    url: `${pre}/payment`,
    method: "post",
    data,
  });
}

let _pre = '';
if (process.env.NODE_ENV !== "development") {
  _pre = "/api/sa/prslcenter";
}
// 查询个人收货地址集合
export function queryAddrList() {
  return request({
    url: `${_pre}/personal/addr/queryList`,
    method: "get",
  });
}
